<template>
  <el-dialog
    append-to-body
    :title="info"
    :visible.sync="dialogVisible"
    align="left"
    :close-on-click-modal="false"
    v-loading="currLoading"
    element-loading-text="拼命加载中"
    element-loading-spinner="el-icon-loading"
    element-loading-background="rgba(0, 0, 0, 0.8)"
    width="1150px">
    <div v-if="dialogVisible && detail.id>0">
      <order-group-box :detail="detail" :reload-detail="getDetail"/>
    </div>
  </el-dialog>
</template>

<script>
import MemberItem from '../Common/MemberItem'
import ProductItem from '../Common/ProductItem'
import OrderGroupBox from '../Common/OrderGroupBox'

export default {
  name: 'OrderGroupDialog',
  components: {OrderGroupBox, ProductItem, MemberItem},
  data: function () {
    return {
      info: '团购订单详情',
      dialogVisible: false,
      currLoading: false,
      detail: {
        id: 0
      }
    }
  },
  mounted () {
  },
  methods: {
    open: function (detail) {
      // this.detail = detail
      this.getDetail(detail.id)
      this.$forceUpdate()
    },
    reloadDetail: function () {
      var id = this.detail.id
      let $this=this
      $this.detail.id = 0
      $this.$forceUpdate()
      setTimeout(function () {
        $this.getDetail(id)
      },300)
    },
    getDetail (id) {
      let $this = this
      $this.MyRequest($this.ApiDoNameShop + 'Order/getGroupDetail', {id}, function (data) {
        $this.detail = data
        $this.dialogVisible = true
        $this.$forceUpdate()
      }, function (res) {
        $this.$message.error(res.message)
        $this.loading = false
      })
    }
  }
}
</script>

<style scoped>

</style>
